package com.gs.weather.vo;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Legolas
 * Date: 2017/10/23 0023
 */
public class PageBean<T> implements Serializable{

    private Integer currentPage;
    private Integer totalPage;
    private List<T> content = new ArrayList<T>();

    public PageBean() {

    }

    public PageBean(List<T> list) {
        if(list instanceof Page) {
            Page<T> page = (Page<T>) list;
            this.currentPage = page.getPageNum();
            this.totalPage = page.getPageSize();
            this.content = page.getResult();
        }
    }

    public PageBean(Integer currentPage, Integer totalPage, List<T> content) {
        this.currentPage = currentPage;
        this.totalPage = totalPage;
        this.content = content;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getContent() {
        return content;
    }

    public void setContent(List<T> content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "PageResult{" +
                "currentPage=" + currentPage +
                ", totalPage=" + totalPage +
                ", content=" + content +
                '}';
    }
}
